package DataStruction;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeMap;

public class Map {
    public static void main(String[] args) {
        TreeMap1();
        Map1();
        province();
    }

    public static void Map1() {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("洛天依", "lty");
        hashMap.put("乐正绫", "yzl");
        System.out.println(hashMap);
        hashMap.forEach((key, value) -> System.out.println(key + "=" + value));
    }

    public static void TreeMap1() {
        TreeMap<Integer, String> treeMap = new TreeMap<>();
        treeMap.put(4, "sb");
        treeMap.put(3, "sb");
        treeMap.put(1, "sb");
        treeMap.put(2, "sb");
        treeMap.forEach((index, value) -> System.out.println(index + "=" + value));
    }

    //    列出省对应的市
    public static void province() {
        HashMap<String, ArrayList<String>> hashMap = new HashMap<>();
        ArrayList<String> city1 = new ArrayList<>();
        city1.add("成都市");
        city1.add("绵阳市");
        city1.add("德阳市");
        ArrayList<String> city2 = new ArrayList<>();
        city2.add("宁波市");
        city2.add("杭州市");
        city2.add("阿爸阿爸市");
        ArrayList<String> city3 = new ArrayList<>();
        city3.add("上海市");
        city3.add("北京市");
        city3.add("不存在市");
        hashMap.put("四川省", city1);
        hashMap.put("浙江省", city2);
        hashMap.put("天朝", city3);
        hashMap.forEach((o1, o2) -> {
            System.out.print(o1 + " =");
            for (String s : o2) {
                System.out.print(" " + s);
            }
            System.out.println();
        });
    }
}
